<include file="public@header"/>
</head>
<body>
<div class="wrap">
    <h1>成员列表</h1>
    <form class="form-inline">
        <div class="form-group">
            <label for="name">成员名</label>
            <input class="form-control" id="name" name="name" value="{:isset($params['name'])?$params['name']:''}"/>
        </div>
        <div class="form-group">
            <label for="clan">房族</label>
            <select name="clan_id" id="clan" class="form-control">
                <option value="">请选择...</option>
                <option value="0" <if condition="isset($data) && $data.clan_id==0">selected="selected"</if>>无</option>
                <foreach name="clan_tree" item="vo">
                    <option value="{$vo.id}" <if condition="isset($params['clan_id']) && $params['clan_id']==$vo.id">selected="selected"</if>><for start="0" end="$vo.level">|-</for>{$vo.name}</option>
                </foreach>
            </select>
        </div>
        <div class="form-group">
            <label for="generation">世代</label>
            <input class="form-control" id="generation" type="number" min="1" value="{:isset($params['generation'])?$params['generation']:''}" name="generation"/>
        </div>
        <button type="submit" class="btn btn-primary">确定</button>
    </form>
    </div>
<div class="wrap">
    <table class="table">
        <thead>
            <tr>
                <th>名字</th>
                <th>所属房族</th>
                <th>性别</th>
                <th>家庭排行</th>
                <th>父亲</th>
                <th>丈夫</th>
                <th>世代</th>
                <th>创建时间</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        <foreach name="list" item="vo">
            <tr>
                <td>{$vo.name}</td>
                <td>{$vo.clan_name}</td>
                <td>
                    <switch name="vo.gender">
                        <case value="0">未知</case>
                        <case value="1">男</case>
                        <case value="2">女</case>
                    </switch>
                </td>
                <td>{$vo.ranking==0?'未知':$vo.ranking}</td>
                <td>{$vo.father_name}</td>
                <td>{$vo.husband_name}</td>
                <td>{$vo.generation}</td>
                <td>{:date('Y-m-d H:i:s',$vo.create_time)}</td>
                <td>{:date('Y-m-d H:i:s',$vo.update_time)}</td>
                <td>
                    <if condition="$vo.generation!=0">
                    <div class="btn-group" role="group">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            添加成员
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <li><a href="{:url('admin/member/memberAdd',['target_id'=>$vo.id,'type'=>1])}">添加子女</a></li>
                            <li><a href="{:url('admin/member/memberAdd',['target_id'=>$vo.id,'type'=>2])}">添加配偶</a></li>
                        </ul>
                    </div>
                    </if>
                    <if condition="$vo.generation!=1">
                    <a href="{:url('admin/member/memberEdit',['id'=>$vo.id])}" class="btn btn-primary">编辑成员</a>
                    <button class="btn btn-primary btn-delete" data-toggle="modal" data-target="#modalDelete" data-id="{$vo.id}">删除成员</button>
                    </if>
                </td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page|default=''}</div>
</div>
<div class="modal fade" tabindex="-1" role="dialog" id="modalDelete" aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="gridSystemModalLabel">是否确定删除</h4>
            </div>
            <div class="modal-body">
                您正在进行删除成员操作，如果您删除的是本族的成员，那么他的老婆以及子女都会被同时删除，确定吗？
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="delSubmit" data-id="">确定</button>
            </div>
        </div>
    </div>

</div>
<script>
    $(function(){
       $('.btn-delete').click(function(){
           var id = $(this).attr('data-id');
           $('#delSubmit').attr('data-id',id);
       });
        $('#delSubmit').click(function(){
            var id = $(this).attr('data-id');
            location.href = '/admin/member/memberDelete/id/'+id;
        })
    });
</script>
</body>
</html>